import java.util.Stack;

public class Office09 {
    public static void main(String[] args) {
        CQueue obj = new CQueue();
        obj.appendTail(3);

        System.out.println(obj.deleteHead());
        System.out.println(obj.deleteHead());

//        obj.deleteHead();
    }

}

class CQueue {

    private Stack<Integer> stack1;
    private Stack<Integer> stack2;

    CQueue() {
        stack1 = new Stack<>();
        stack2 = new Stack<>();
    }


    public void appendTail(int value) {
        stack1.push(value);
    }

    public int deleteHead() {
        if (stack2.isEmpty()) {
            while (!stack1.isEmpty()) {
                stack2.push(stack1.pop());
            }
        }
        if (!stack2.isEmpty())
            return stack2.pop();
        return -1;
    }
}

/**
 * Your CQueue object will be instantiated and called as such:
 * CQueue obj = new CQueue();
 * obj.appendTail(value);
 * int param_2 = obj.deleteHead();
 */